package be.bonamis.umpire.domain;

import java.util.List;

import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;

@Entity
@Table(name = "UMPIRE")
@PrimaryKeyJoinColumn(name = "PERSON_ID")
public class Umpire extends Person implements Comparable<Umpire> {

	private String dispoName;
	@ManyToOne
	private Ranking ranking;
	@OneToMany
	private List<UmpireLeagueDay> days;

	public Ranking getRanking() {
		return ranking;
	}

	public void setRanking(Ranking ranking) {
		this.ranking = ranking;
	}

	public String getDispoName() {
		return dispoName;
	}

	public void setDispoName(String dispoName) {
		this.dispoName = dispoName;
	}

	public List<UmpireLeagueDay> getDays() {
		return days;
	}

	public void setDays(List<UmpireLeagueDay> days) {
		this.days = days;
	}

	@Override
	public int compareTo(Umpire u) {		
		int lastCmp = ranking.compareTo(u.ranking);		
		lastCmp = lastCmp != 0 ? lastCmp : getLastName().compareTo(u.getLastName());
		return (lastCmp != 0 ? lastCmp : getFirstName().compareTo(u.getFirstName()));
	}

}
